package jlfm.lastfm.apps.recorder;

import jlfm.lastfm.client.TrackMetadata;
import jlfm.lastfm.client.impl.simple.StreamHandler;

public class ProgressEvent {
	private int estimatedTime;

	private int totalTime;

	private double perCent;

	private TrackMetadata metadata;

	private StreamHandler source;

	protected ProgressEvent(StreamHandler source, TrackMetadata m, long bytes) {
		this.source = source;
		this.metadata = m;
		int dur = m.getTrackDuration();
		totalTime = dur;
		int totalBytes = 128000 * dur / 8;
		if (dur > 0) {
			perCent = (bytes / (double) totalBytes);
			estimatedTime = (int) (perCent * dur);
		}
	}

	public int getEstimatedTime() {
		return estimatedTime;
	}

	public int getTotalTime() {
		return totalTime;
	}

	public double getPerCent() {
		return perCent;
	}

	public TrackMetadata getMetadata() {
		return metadata;
	}

	public void setMetadata(TrackMetadata metadata) {
		this.metadata = metadata;
	}

	protected StreamHandler getSource() {
		return source;
	}

	protected void setSource(StreamHandler source) {
		this.source = source;
	}
}
